<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use App\Utils\QueryUtil;


class CreateTableProjectsAbout extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('project_cates', function (Blueprint $table) {
            $table->id();
            $table->string('name', 16)->default('')->comment('分类名称');
            $table->string('icon', 128)->default('')->comment('图标');
            $table->integer('sort')->default(200)->comment('排序');
            $table->string('tags', 255)->default('')->comment('分类标签');
            $table->string('remark', 255)->default('')->comment('分类说明');
            $table->tinyInteger('enable')->default(1)->comment('状态 1展示 0不展示');
            $table->timestamps();

            $table->unique(['name']);
            $table->index(['sort', 'tags']);
        }); QueryUtil::tableComment('project_cates', '项目分类表');

        Schema::create('projects', function (Blueprint $table) {
            $table->id();
            $table->integer('cate_id')->default(0)->comment('项目分类ID project_cates.id');
            $table->string('icon', 128)->default('')->comment('项目图标');
            $table->string('name', 64)->default('')->comment('项目名称');
            $table->string('remark', 255)->default('')->comment('项目说明');
            $table->string('note', 255)->default('')->comment('项目备注');
            $table->string('tags', 255)->default('')->comment('项目标签');
            $table->string('created_adminer')->default('')->comment('项目创建人 如 马文欢(17614322265)');
            $table->string('updated_adminer')->default('')->comment('项目最后修改人 如 马文欢(17614322265)');
            $table->integer('sort')->default(1)->comment('项目排序');
            $table->tinyInteger('enable')->default(1)->comment('上下架状态 1上架 0下架');
            $table->timestamps();

            $table->unique(['name']);
            $table->index(['cate_id', 'tags', 'sort']);
        });  QueryUtil::tableComment('projects', '项目表');

        Schema::create('products', function (Blueprint $table) {
            $table->id();
            $table->string('icon', 128)->default('')->comment('产品图标');
            $table->integer('cate_id')->default(0)->comment('项目分类ID project_cates.id');
            $table->integer('project_id')->default(0)->comment('项目ID projects.id');
            $table->string('name', 64)->default('')->comment('产品名称');
            $table->string('version', 64)->default('')->comment('产品版本');
            $table->string('remark', 255)->default('')->comment('产品说明');
            $table->string('note', 255)->default('')->comment('产品备注');
            $table->string('tags', 255)->default('')->comment('产品标签');
            $table->string('created_adminer')->default('')->comment('产品创建人 如 马文欢(17614322265)');
            $table->string('updated_adminer')->default('')->comment('产品最后修改人 如 马文欢(17614322265)');
            $table->integer('sort')->default(1)->comment('产品排序');
            $table->tinyInteger('enable')->default(1)->comment('上下架状态 1上架 0下架');
            $table->timestamps();

            $table->unique(['name']);
            $table->index(['tags', 'sort', 'cate_id', 'project_id']);
        });  QueryUtil::tableComment('products', '产品表');

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('table_projects_about');
    }
}
